<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String action=request.getParameter("action");
	boolean loginErro=false;
	if(action!=null){
		if(action.equalsIgnoreCase("login")){
			String loginName=request.getParameter("loginName");
			String password=request.getParameter("password");
			
			///read d//
			//select * from User where loginName=? and password=?
			if(loginName.equals(password)){
				System.out.println("login success");
				session.setAttribute("CurrentUser", loginName);
				response.sendRedirect("prv/p1.jsp");
				
			}else{
				System.out.println("login failure");
				loginErro=true;
			}					
		}
	}
	
	System.out.println("No Action");

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div id="erro" style="color:red"><%=loginErro?"Login Erro":"" %>
	</div>
	<form method="post" action="login.jsp?action=login">
		LoginName:<input type="text" name="loginName"><br/>
		Password:<input type="password" name="password"><br/>
		<input type="submit" value="Login"><br/>
	</form>
</body>
</html>